﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;


namespace ParadiseShophcm.Control
{
  
    public partial class ShowSanPham : System.Web.UI.UserControl
    {
        DataProvider dp = new DataProvider();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LoadSP();
                
            }
        }
        public void LoadSP()
        {
            String que = "Select MaSanPham,TenSanPham,Gia,HinhAnh From SanPham Where isDelete = 0";
            DataTable dt = new DataTable();
            dt = dp.ExecuteQuery (que,null );

            for (int i = 0; i < dt.Rows.Count; i ++ )
            {
                string chuoi = dt.Rows[i][1].ToString();
                if(chuoi.Length > 50)
                {
                    dt.Rows[i][1] = chuoi.Substring(0, 25) + "....";
                }
            }

            PhanTrang.PageSize = 9;
            PhanTrang.DataSource = dt.DefaultView;
            PhanTrang.BindToControl = DTLShowsp;

            DTLShowsp.DataSource = PhanTrang.DataSourcePaged;

            
            //DTLShowsp.DataBind();

            DTLShowsp.DataBind();

            
        }
        
    }
}